<?php


namespace App\Http\Middleware;


use App\Base\BaseFunc;
use Closure;

class AdminLoginCheck
{
    public function __construct(BaseFunc $baseFunc)
    {
        $this->baseFunc = $baseFunc;
    }
    /**
     * Handle an incoming request.
     *
     * @param \Illuminate\Http\Request $request
     * @param \Closure $next
     * @return mixed
     */
    public function handle($request, Closure $next)
    {
        if (session("admin_id") != null) {
            return $next($request);//行为无需检测直接放行
        } else {
            return $this->baseFunc->setRedirectMessage(false, "本操作需要登录", NULL, "/adminLogin");
        }
    }
}